package com.lr.configurer;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebMvcConfigurer implements WebMvcConfigurer {
    @Value("${VDirPath}")
    private String VDirPath;
    //重写资源处理方法
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //注册虚拟资源
        registry.addResourceHandler("/image/**")
                .addResourceLocations("file:/"+VDirPath+"/");
        WebMvcConfigurer.super.addResourceHandlers(registry);
    }
}

